#include <pfcGlobal.h>
#include <wfcClient.h>
#include <uifcDefaultListeners.h>
#include <logger.h>
#include <wxyutils.h>
#include <pfcAsyncConnection.h>
#include <ProSizeConst.h>

#define MSGFILE "BatchExport.txt"

wfcStatus BatchExport();

//程序入口
extern "C" int user_initialize(
    int argc,
    char *argv[],
    char *version[],
    char *build,
    wchar_t errbuf[80])
{
    string dllpath;
    GetDllPath(dllpath);
    initLogger(dllpath + "info.log", dllpath + "warn.log", dllpath + "error.log");
#ifdef UNICODE
    LOG(LOG_INFO) << "#define UNICODE";
#endif
    pfcSession_ptr session = pfcGetProESession();
    try
    {
        pfcUICommand_ptr BatchExport_com = CreateUICommand(session, "BatchExport_com", new MycallbackClass(BatchExport),
                                                           MSGFILE, "BatchExport", "BatchExport", "BatchExport",
                                                           new MyActionAccess(pfcACCESS_AVAILABLE));
        //设置快捷键
        session->SetConfigOption("mapkey", "obe ~ Command `BatchExport_com`;");
    }
    OTK_EXCEPTION_PRINT_LOG
    catch (const std::exception &e)
    {
        std::cerr << e.what() << '\n';
    }

    return 0;
}
//程序出口
extern "C" void user_terminate()
{
}
int main(int argc, char *argv[])
{
    char proe_command[PRO_PATH_SIZE], text_path[PRO_PATH_SIZE];

    strcpy(proe_command, "C:\\Program Files\\PTC\\Creo 6.0.4.0\\Parametric\\bin\\parametric.exe");
    strcpy(text_path, "E:\\creo-secondary-development\\1.2BatchExport\\text");

    pfcAsyncConnection_ptr connection = pfcAsyncConnection::Start(proe_command, text_path);
    pfcSession_ptr session = connection->GetSession();
    session->LoadConfigFile("D:\\PTC\\config\\config.pro");
    connection->WaitForEvents();
    // connection->EventProcess();
    connection->End();
    return 0;
}